ACTOR PowerHDLevel2 : CustomInventory
{
inventory.maxamount 1
}

ACTOR MageMeleeStaff : BrutalWeapon
{
  Weapon.SelectionOrder 3000
  Weapon.YAdjust 5
  Weapon.SlotPriority 1
  Tag "$TAG_STAFF"
  Weapon.SlotNumber 1
  //+NOALERT
  +THRUGHOST
  +WIMPY_WEAPON
  +MELEEWEAPON
  +NOEXTREMEDEATH
  +DONTSPLASH
  	Obituary "%o was staffed by %k"
	+WEAPON.MELEEWEAPON
    +WEAPON.NOALERT
    +WEAPON.NOAUTOAIM
	+WEAPON.CHEATNOTWEAPON
	Inventory.ForbiddenTo BDoomer, Paladin, Sorcerer
  States
  {
  Spawn:
    TNT1 A -1
    Stop
	Ready:
		// This is placed here for now, should be moved if there is a replaying
		// idle animation for weapons
	ReadyLoop:
		STAF A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
  PoweredReady:
    STFF DEF 2 A_WeaponReady (WRF_ALLOWRELOAD)
    Goto Ready
	
  Deselect:
	TNT1 A 0 A_Lower
    Loop
	
  Select:
    STAF A 0 A_Raise
    STAF A 1 A_Raise
    Loop
	
  PoweredDeselect:
    STFF E 0 A_Lower
    STFF E 1 A_Lower
    Goto Deselect
	
  PoweredSelect:
    STFF F 0 A_Raise
    STFF F 1 A_Raise
    Goto Select
	
  Fire:
    TNT1 A 0 A_JumpIfInventory("PowerHDLevel2",1,"PoweredFire")
	goto Fire1
	
  Fire1:
	STAF A 1 Offset(0,62)
    STAF A 1 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-3)
	STAF B 1 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -9)
	STAF B 1 // A_CustomPunch(random(10,15),TRUE,0,"BrutalStaffPuff",104)
	STAF C 2
    STAF B 1
	TNT1 A 0 A_Recoil(2)
	STAF A 1
	STAF A 1 Offset(0,62)
	TNT1 A 2
    TNT1 A 0 A_ReFire("Fire2")
    Goto Ready

		//A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -9)
		//A_FireCustomMissile("KickAttack", 0, 0, 0, -2)

	
  Fire2:
    STAF D 2 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-1)
	STAF E 1 
	STAF M 1 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -9) //A_CustomPunch(random(20,30)+(CallACS("StrengthCalculator")/3),TRUE,0,"BrutalStaffPuff",128)
	STAF M 1
    STAF E 1 
	TNT1 A 0 A_Recoil(1)
	STAF D 2
	TNT1 A 2
    TNT1 A 0 A_ReFire("Fire3")
    Goto Ready
	
  Fire3:
    STAF F 2 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-1)
	STAF G 1 
	STAF H 1 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -9) //A_CustomPunch(random(35,55)+(CallACS("StrengthCalculator")/3),TRUE,0,"BrutalStaffPuff",128)
	STAF H 1
    STAF G 1 
	TNT1 A 0 A_Recoil(1)
	STAF F 1
	TNT1 A 2
    TNT1 A 0 A_ReFire("Fire4")
    Goto Ready
	
  Fire4:
  	STAF I 1 Offset(0,62)
    STAF I 1 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-3)
	STAF J 1 
	STAF L 1 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -9) // A_CustomPunch(random(45,70)+(CallACS("StrengthCalculator")/3),TRUE,0,"BrutalStaffPuff",104)
	STAF L 1  
    STAF J 1	
	TNT1 A 0 A_Recoil(2)
	STAF I 1
	STAF I 1 Offset(0,62)
	TNT1 A 1
    TNT1 A 0 A_ReFire("Fire2")
    Goto Ready
	
  AltFire:
	TNT1 A 0 
  SuperAttack:
    TNT1 A 0 A_PlayWeaponSound("WHOP")
	TNT1 A 0 A_SetReflective
	TNT1 A 0 A_SetGravity(0.7)
	SSPN A 2 //A_FireCustomMissile("KickAttack", 0, 0, 0, -2) //A_CustomPunch(random(10,20),TRUE,CPF_NOTURN|CPF_STEALARMOR,"BrutalStaffPuff",64,0.5)
	SSPN B 1 A_SetReflectiveInvulnerable
	SSPN C 2
	TNT1 A 0 A_UnSetReflectiveInvulnerable
	SSPN F 2 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -2) //A_CustomPunch(random(10,20),TRUE,CPF_NOTURN|CPF_STEALARMOR,"BrutalStaffPuff",64,0.5)
	TNT1 A 0 A_UnSetReflective
	TNT1 A 0 A_SetGravity(1)
	TNT1 A 0 A_Refire("Superattack")
	Goto Ready
  PoweredHold:
    TNT1 A 0 A_PlayWeaponSound("WHOP")
	TNT1 A 0 A_SetReflective
	TNT1 A 0 A_SetGravity(0.7)
	TNT1 A 0 A_RadiusThrust(-650,640,RTF_NOIMPACTDAMAGE)
	TNT1 A 0 A_RadiusThrust(-50,640,RTF_NOIMPACTDAMAGE)
	SSPN A 1 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -2) //A_CustomPunch(random(10,20)+(CallACS("StrengthCalculator")/3),TRUE,CPF_NOTURN|CPF_STEALARMOR,"BrutalStaffPuff",64,1)
	TNT1 A 0 A_RadiusThrust(-650,640,RTF_NOIMPACTDAMAGE)
	TNT1 A 0 A_RadiusThrust(-5,640,RTF_NOIMPACTDAMAGE)
	SSPN B 1 A_SetReflectiveInvulnerable
	TNT1 A 0 A_RadiusThrust(-650,640,RTF_NOIMPACTDAMAGE)
	TNT1 A 0 A_RadiusThrust(-5,640,RTF_NOIMPACTDAMAGE)
	SSPN C 1
	TNT1 A 0 A_UnSetReflectiveInvulnerable
	TNT1 A 0 A_RadiusThrust(-650,640,RTF_NOIMPACTDAMAGE)
	TNT1 A 0 A_RadiusThrust(-5,640,RTF_NOIMPACTDAMAGE)
	SSPN F 1 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, -2) //A_CustomPunch(random(10,20)+(CallACS("StrengthCalculator")/3),TRUE,CPF_NOTURN|CPF_STEALARMOR,"BrutalStaffPuff",64,1)
	TNT1 A 0 A_UnSetReflective
	TNT1 A 0 A_SetGravity(1)
	Goto Ready
	
  PoweredFire:
  PoweredFire1:
	STFF F 1 Offset(0,62)
    STFF F 1 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-3)
	STFF G 1 
	STFF H 1 A_CustomPunch(random(15,25) + (CallACS("StrengthCalculator")),TRUE,0,"BrutalPoweredStaffPuff",104)
	STFF H 2
    STFF G 1
	TNT1 A 0 A_Recoil(2)
	STFF F 1
	STFF F 1 Offset(0,62)
	TNT1 A 2
    TNT1 A 0 A_ReFire("PoweredFire2")
    Goto Ready
	
  PoweredFire2:
	goto Ready
	STFR A 1 Offset(0,62)
    STFR A 1 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-3)
	STFR B 1 
	STFR C 1 A_CustomPunch(random(25,40)+(CallACS("StrengthCalculator")),TRUE,0,"BrutalPoweredStaffPuff",104)
	STFR C 2
    STFR B 1
	TNT1 A 0 A_Recoil(2)
	STFR A 1
	STFR A 1 Offset(0,62)
	TNT1 A 2
    TNT1 A 0 A_ReFire("PoweredFire3")
    Goto Ready
	
  PoweredFire3:
	TNT1 A 0 A_JumpIfInventory("PowerHDLevel2",1,2)
	goto Ready
	STFL A 1 Offset(0,62)
    STFL A 1 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-3)
	STFL B 1 
	STFL C 1 A_CustomPunch(random(35,55)+(CallACS("StrengthCalculator")),TRUE,0,"BrutalPoweredStaffPuff",104)
	STFL C 2 
    STFL B 1
	TNT1 A 0 A_Recoil(2)
	STFL A 1
	STFL A 1 Offset(0,62)
	TNT1 A 2
    TNT1 A 0 A_ReFire("PoweredFire4")
    Goto Ready
	
  PoweredFire4:
	TNT1 A 0 A_JumpIfInventory("PowerHDLevel2",1,2)
	goto Ready
  	STAF I 1 Offset(0,62)
    STAF I 1 A_PlayWeaponSound("STAFSWNG")
	TNT1 A 0 A_Recoil(-3)
	STAF J 2 
	STFC A 1 A_CustomPunch(random(45,70)+(CallACS("StrengthCalculator")*2),TRUE,0,"BrutalPoweredStaffPuff",104)
	STFC A 2  
    STAF J 2
	TNT1 A 0 A_Recoil(2)
	STAF I 1
	STAF I 1 Offset(0,62)
	TNT1 A 2
	TNT1 A 0 A_ReFire("PoweredFire2")
    Goto Ready
  }
}

Actor BrutalStaffPuff : BulletPuff
{
	VSpeed 0
	Alpha 0.9
	Renderstyle Add
	+FORCEXYBILLBOARD
	-ALLOWPARTICLES
	+NOEXTREMEDEATH
	+PUFFONACTORS
	+ALWAYSPUFF
	+MTHRUSPECIES
	Scale 0.13
	+NOEXTREMEDEATH
	-ALWAYSPUFF
	+THRUGHOST
	DamageType "Staff"
	States
	{
	Melee:
	Spawn:
		TNT1 A 0
		TNT1 AA 0 //ACS_NamedExecuteAlways("GetFloorTypeXTerrain",0)
		TNT1 AAAAA 0 A_SpawnItemEx("BrutalStaffPuffSpark",0,0,4,frandom(-3.2,3.2),frandom(-3.2,3.2),frandom(-3.2,3.2))
		KTPF A 1 Bright Light("STAFPUFF01") A_PlaySound("STAFHIT1")
	Death:
		KTPF A 0 A_SetScale(scalex*0.7,scaley*0.7)
		KTPF A 1 Bright Light("STAFPUFF02")A_FadeOut(0.1)
		KTPF A 0 A_SetScale(scalex*0.7,scaley*0.7)
		KTPF A 1 Bright Light("STAFPUFF03")A_FadeOut(0.1)
		KTPF A 0 A_SetScale(scalex*0.7,scaley*0.7)
		KTPF A 1 Bright Light("STAFPUFF04")A_FadeOut(0.1)
		KTPF A 0 A_SetScale(scalex*0.7,scaley*0.7)
		KTPF A 1 Bright Light("STAFPUFF05")A_FadeOut(0.1)
	Fade:
		KTPF A 0 A_SetScale(scalex*0.7,scaley*0.7)
		KTPF A 1 Bright A_FadeOut(0.1)
		Loop
	XDeath:
	    TNT1 A 1 A_PlaySound("STAFHIT2")
		Stop
	}
}
Actor BrutalStaffPuffSpark
{
  Radius 2
  Height 2
  RenderStyle Add
  Alpha 0.9
  Scale 0.045
  +NOINTERACTION
  +CLIENTSIDEONLY
  +FORCEXYBILLBOARD
  +NOGRAVITY
  +DONTSPLASH
  States
  {
  Spawn:
    KTPF A 1 Bright A_FadeOut(0.05)
	KTPF A 0 Bright A_SetScale(scalex*0.79,scaley*0.79)
	KTPF A 0 A_ChangeVelocity(frandom(-1,1),frandom(-1,1),frandom(-1,1),CVF_RELATIVE)
    loop
  }
}

ACTOR BrutalPoweredStaffPuff
{
  +NOBLOCKMAP
  +NOGRAVITY
  +PUFFONACTORS
  +FORCEXYBILLBOARD
  -THRUGHOST
  RenderStyle Add
  Alpha 0.9
  VSpeed 0.0
  Scale 0.34
  Decal "WallCrack"
  DamageType "PowerStaff"
  States
  {
  Spawn:
    TNT1 A 0 NoDelay A_PlaySound("STAFWALL")
	Goto Puff
  XDeath:
	TNT1 A 0 A_PlaySound("STAFHIT2")
  Puff:
    PUF4 AABBCCDDEEFF 1 Bright A_SpawnItemEx("BlueFlare",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
    Stop
  }
}